package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemProfessinalTeamBinding;
import com.sgb.kjwl.model.entity.enterprise.ProfessionalTeamEntity;

import java.util.List;

public class ProfessionalTeamAdapter extends RecyclerView.Adapter<ProfessionalTeamAdapter.ViewHolder> {

    private Context context;
    private List<ProfessionalTeamEntity> mData;

    public ProfessionalTeamAdapter(Context context, List<ProfessionalTeamEntity> mData) {
        this.context = context;
        this.mData = mData;
    }

    @NonNull
    @Override
    public ProfessionalTeamAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ViewDataBinding viewDataBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.item_professinal_team,parent,false);
        return new ProfessionalTeamAdapter.ViewHolder(viewDataBinding);
    }

    @Override
    public void onBindViewHolder(@NonNull ProfessionalTeamAdapter.ViewHolder holder, int position) {
        ProfessionalTeamEntity p = mData.get(position);
        ItemProfessinalTeamBinding itemProfessinalTeamBinding = (ItemProfessinalTeamBinding) holder.getBindings();
        itemProfessinalTeamBinding.setPte(p);
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        ViewDataBinding carriageDemandBinding;

        public ViewHolder(ViewDataBinding  view) {
            super(view.getRoot());
            this.carriageDemandBinding = view;
        }

        public ViewDataBinding  getBindings(){
            return carriageDemandBinding;
        }
    }
}
